home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / srefv12i.zip / interpet.in < prev    next >
Text File  |  1996-10-07  |  5KB  |  138 lines

  1. ; This file contains "INTERPRET" rexx-code blocks for use by
  2. ;the INTERPRET keyphrase of SRE-FILTER. 10/96
  3. ; OBSOLETE: We recommend use of dedicated "rexx code block files" (*.RXX files)
  4. ;           or the use of the INTERPRET CODE xxx ;yyy.
  5. ;
  6. ;Each rexx-code block should be labeled with a {label}, then the rexx-code
  7. ;block  follows, with the next label (or eof) signalling the end
  8. ;of the block.
  9. ;
  10. ;General Usage notes:
  11. ;
  12. ;   To include output in the document, store results in INTERRET.RESULTS
  13. ;
  14. ;   Seperate rexx-code lines with a semi-colon
  15. ;
  16. ;   In addition to the functions available through goserve (including
  17. ;   REQFIELD, SERVERNAME(), CLIENTNAME(), etc.), SREFILTER provides the following
  18. ;  variables:
  19. ;     crlf : the line seperator
  20. ;     tmp.  : To be safe, store temporary results in tmp.xx variables
  21. ;     dir   : Working directory (i.e. E:/GOHTTP/)
  22. ;     who: ip of requester
  23. ;     whoport: port of requester
  24. ;     request : request #
  25. ;     transaction: transaction # (maybe several transactions per request)
  26. ;     tempfile: Unique file name for this transaction (use for a working file)
  27. ;     myaddr: Server's ip
  28. ;     sel : Orginal request string
  29. ;
  30. ;
  31. ;Some sample Code Blocks:
  32. ;  Several samples are included below. Of particular interest is  USE_TABLE.;
  33. ;
  34. ;  USE_TABLE : Detects whether the requesting browser understands the
  35. ;             TABLE element. If so, INCLUDES  xxx.TBL, if not, includes xxx.DEF.
  36. ;  GET_HIT:   Finds # of hits for current URL (NOT including this one).
  37. ;              Returns result in CURRENT_HIT.NUM
  38. ;  AUGMENT_HIT: Same as GET_HIT, but does include current hit (that is, it
  39. ;                modifies COUNTER.CNT.
  40. ; AUDIT_CLIENTNAME: Write the client ip name to the audit file
  41. ;
  42. ;
  43. ; Notes
  44. ;  GET_HIT and AUGMENT_HIT are useful if you
  45. ;          call an external procedure that creates counter GIFS.
  46. ;
  47. ;  Details on USE_TABLE:
  48. ;        xxx is the name of the action -- and xxx.TBL and xxx.DEF should be
  49. ;        in the SAME DIRECTORY AS THE HTML DOCUMENT!!
  50. ;
  51. ;        The ambitious user may wish to augment the TABLE_LIST stem variable.
  52. ;
  53. ;         The USETABL2.RXX  file contains a more sophisticated version of 
  54. ;         USE_TABLE,
  55. ;           ..if the browser does not appear on the
  56. ;             "table_list", a "tell me if you can handle TABLEs" document is
  57. ;              sent back.. and depending on the answer, either xxx.TBL 
  58. ;              or xxx.DEF is included.
  59. ;
  60. ;---- End comments section.
  61.  
  62. {TEST1}  interpret=results=' <h3> This is a test </h3> '
  63.  
  64. {GO_to_bed}   tmp.jj=time('h') ; SAY " BED 1 " ;
  65.              if tmp.jj<5 | tmp.jj>20 then do ;
  66.                   interpret.results= ' <STRONG> It  is very late</STRONG> ' ;
  67.          interpret.results=interpret.results||crlf||" aren't   you tired? " ;
  68.              end ;
  69.  
  70. {AUDIT_CLIENTNAME}
  71.    if clientname0=0 then ;
  72.              TMP1=clientname() ;
  73.           else ;
  74.             TMP1=clientname0 ;
  75.    audit " Client Name: " tmp1 ' on ' date() ;
  76.  
  77.  
  78.  
  79. {GOOD_MORNING }
  80.           tmp.jj=time('h') ;
  81.           select ;
  82.           when tmp.jj<7 then
  83.                tmp='<em> It is very early? </em> ' ;
  84.           when tmp.jj<12 & temp.jj > 6 then
  85.                tmp='<em> Good morning </em> ' ;
  86.           when tmp.jj<19 & temp.jj > 11 then
  87.                tmp='<em> Good afternoon </em> ' ;
  88.           otherwise
  89.                tmp='<em> Good evening.. </em> ' ;
  90.           end ;
  91.           interpret.results=tmp
  92.  
  93. {get_hit} /* Get current # of hits (NOT including this one), store in current_hit.num */
  94.            current_hit.num=lookup_count(counter_file,action) ; say ' Hits = ' current_hit.num;
  95.  
  96. {augment_hit}  /* Augment # of hits, save results in current_hit.num, do not
  97.                      display results */
  98.          current_hit.num=lookup_count(counter_file,action,'ADD') ;say ' +Hits = 'current_hit.num;
  99.  
  100.  
  101. {USE_TABLE}
  102.  
  103.   /* -- add "table capable browser" User-agent identifiers here -- */
  104.   /* Note that "abbreviation match is performed (don't worry about extra
  105.      stuff after the last character in each table_list entry) */
  106.   table_list.1='IBM WebExplorer DLL /v1.03' ;
  107.   table_list.2="Mozilla/2.0";
  108.   table_list.3="Mozilla/1.1";
  109.   table_list.4="Mozilla/1.2";
  110.   table_list.5="Mozilla/1.3";
  111.    table_list.6="IBM-WebExplorer-DLL/v1.1";
  112.  
  113.  
  114.  
  115.   table_list.0=6 ;
  116.  
  117.   /* -- do not change below here --- */
  118.  
  119.   putme=reqfield("User-Agent") ;
  120.   isat=lastpos('.',docname);
  121.   docname0=docname ;
  122.   if isat>0 then
  123.       docname0=delstr(docname,isat) ;
  124.   docname1=docname0||'.DEF' ;
  125.   if putme<>" " then do ;
  126.      do mm=1 to table_list.0 ;
  127.        if abbrev(translate(putme),translate(table_list.mm))=1 then do;
  128.          docname1=docname0||'.TBL' ;
  129.          leave ;
  130.        end ;
  131.      end;
  132.   end;
  133.   interpret.results=delim_1.1||'INCLUDE  '||docname1||delim_2.1 ;
  134.  
  135.  
  136. {END}
  137.  
  138.